package com.ruoyi.aop;


import com.ruoyi.domain.T06;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.service.IT06Service;
import com.ruoyi.service.impl.T06ServiceImpl;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Aspect
@Component
public class UserMarkAspect {
    @Autowired
    private IT06Service it06Service;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private T06ServiceImpl t06ServiceImpl;

    @Before("@annotation(CheckUserMark)")
    public void checkUserMark(JoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        HttpServletRequest request= (HttpServletRequest) args[0];
        Long UserId = tokenService.getLoginUser(request).getUser().getUserId();
        T06 t06 = t06ServiceImpl.selectT06ByF0601(UserId);
        if(t06.getF0610()==0){
            throw new RuntimeException("未被授权，请填写个人信息授权");
        }
    }
}
